export async function fetchBooks(category: string) {
  try {
    const response = await fetch(`${process.env.NEXT_PUBLIC_AWS_API_URL}/books?category=${category}`, {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json',
        // Add any necessary authentication headers
      },
    });
    
    if (!response.ok) {
      throw new Error('Network response was not ok');
    }
    
    return await response.json();
  } catch (error) {
    console.error('Error fetching books:', error);
    return [];
  }
}

export async function updateBookNote(bookId: string, note: string) {
  try {
    const response = await fetch(`${process.env.NEXT_PUBLIC_AWS_API_URL}/books/${bookId}`, {
      method: 'PATCH',
      headers: {
        'Content-Type': 'application/json',
        // Add any necessary authentication headers
      },
      body: JSON.stringify({ note }),
    });
    
    if (!response.ok) {
      throw new Error('Failed to update note');
    }
    
    return await response.json();
  } catch (error) {
    console.error('Error updating note:', error);
    throw error;
  }
} 